/* 
 * Copyright [2018] [Alex/libo(liboms@hotmail.com)]
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.hyts.apidoc.config;

import java.util.*;


import com.hyts.apidoc.base.AnnotationDocConfig;

/** 
 * @title AnalysisConfig.java  
 * @package com.hyts.apidoc.config  
 * @description 
 * 				解析代码文档操作-系统规定解析标准
 * 				所有解析对象都要以此对象为标准  
 * @author libo/Alex
 * @email liboms@hotmail.com/liboware@163.com  
 * @date 2018年4月24日 
 * @version V1.0 
 */
public enum AnalysisConfig implements AnnotationDocConfig{
	  
    INSTANCE("this"),
	/*********文件类型-头名称**************/
	EXT_TYPE_HEADER_TITLE_NAME("@title"),//EXT开头非官方标准要求
	EXT_TYPE_HEADER_TITLE_PACKAGE("@package"),
	TYPE_HEADER_TITLE_DESC("@description"),
	TYPE_HEADER_TITLE_AUTHOR("@author"),
	EXT_TYPE_HEADER_TITLE_EMAIL("@email"),
	TYPE_HEADER_TITLE_DATE("@date"),
	TYPE_HEADER_TITLE_VERSION("@version"),
	TYPE_HEADER_TITLE_SEE("@see"),
	TYPE_HEADER_TITLE_PACKAGE("@package"),
	//特别注释
	TYPE_ATTRIBUTE_OVERTIME("@deprecated"),//@Deprecated
	
	/*********方法-信息字段**************/
	METHOD_HEADER_EXCEPTION("@exception"),
	METHOD_HEADER_THROWS("@throws"),
	METHOD_HEADER_RETURN("@return"),
	METHOD_HEADER_PARAM("@param"),
	METHOD_HEADER_NAME("@name");


	public String code;

	/**  
	 * @constructor：AnalysisConfig  
	 * @param code  
	 */ 
	private AnalysisConfig(String code) {
		this.code = code;
	}

	/**  
	 * @name code's getter method
	 * @return code
	 */
	public String getCode() {
		return code;
	}

	/**  
	 * @name code's setter method
	 * @param code
	 * @return void
	 */
	public void setCode(String code) {
		this.code = code;
	}
	
	
	public AnalysisConfig[] getValues() {
	    List<AnalysisConfig> annotationList = new LinkedList<>();
		ServiceLoader<AnnotationDocConfig> serviceClass = ServiceLoader.load(AnnotationDocConfig.class,
				AnalysisConfig.class.getClassLoader());
		Iterator<AnnotationDocConfig> annotationDocConfigs = serviceClass.iterator();
	    if(!annotationDocConfigs.hasNext()) {
	        return AnalysisConfig.values();
	    }
	    while(annotationDocConfigs.hasNext()){
			AnnotationDocConfig config = annotationDocConfigs.next();
			annotationList.addAll(Arrays.asList(config.getValues()));
		}
	    annotationList.addAll(Arrays.asList(AnalysisConfig.values()));
	    return annotationList.toArray(new AnalysisConfig[annotationList.size()]);
	}
	
}
